package com.ryskoo.permission.role.domain;

import com.ryskoo.framework.core.bean.BasicPO;
import com.ryskoo.permission.menu.domain.MenuPO;
import com.ryskoo.permission.permission.domain.PermissionPO;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

/**
 * 角色持久化对象
 *
 * @author Shawn
 */
@Entity
@Table(name = "PMS_ROLE")
public class RolePO extends BasicPO {
    private static final long serialVersionUID = -2587989543502425535L;
    /**
     * 角色名称
     */
    @Column(name = "name", columnDefinition = "varchar", length = 20, nullable = false)
    private String name;
    /**
     * 角色类型-平台角色、商户角色等类型
     * 0 - 平台角色
     * 1 - 商户角色
     */
    @Column(name = "type", columnDefinition = "tinyint", length = 2, nullable = false)
    private int type = 0;
    /**
     * 角色关联的菜单列表（非持久化字段）
     */
    @Transient
    private List<MenuPO> menuList;
    /**
     * 角色关联的权限列表（非持久化字段）
     */
    @Transient
    private List<PermissionPO> permissionList;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public List<MenuPO> getMenuList() {
        return menuList;
    }

    public void setMenuList(List<MenuPO> menuList) {
        this.menuList = menuList;
    }

    public List<PermissionPO> getPermissionList() {
        return permissionList;
    }

    public void setPermissionList(List<PermissionPO> permissionList) {
        this.permissionList = permissionList;
    }

    @Override
    public String toString() {
        return new StringBuffer(super.toString()).append("RolePO [name=")
                .append(name).append(", type=").append(type).append("]")
                .toString();
    }

}
